﻿using MassTransit;
using MassTransitTest.Enums;
using MassTransitTest.Models;
using MassTransitTest.Request;
using MassTransitTest.SqlSugarCore;

namespace MassTransitTest.Consumers
{
    public class LoginSuccessHandler : IConsumer<LoginSuccessRequest>
    {
        private readonly IDbContext dbContext;
        public LoginSuccessHandler(IDbContext dbContext)
        {
            this.dbContext = dbContext;
        }

        public Task Consume(ConsumeContext<LoginSuccessRequest> context)
        {
            var db = dbContext.GetDbContext(BusinessDbTypeEnum.LBBC.ToString(), DbTypeEnum.Mysql);
            var datas0 = db.QueryMultiple<InfoCity>("select * from info_city where citycd like @cd", new { cd = "10%" });
            var datas1=db.Client.Queryable<InfoCity>().Where(p => p.citycd.StartsWith("10")).ToList();
            datas1 = db.Client.Queryable<InfoCity>().Where(p => p.citycd.Contains("10")).ToList();
            context.RespondAsync<LoginSuccessResponse>(new LoginSuccessResponse
            {
                CouponSended = true,
            }).Wait();
            return Task.CompletedTask;
        }
    }
}
